//
// Created by 123 on 2024/12/31.
//
#include "iostream"
using namespace std;
class Person{
public:
    int ages;
public:
    Person(){
        ages = 0;
    }
    Person(int a){
        ages = a;
    }
    Person(const Person& p){
        ages = p.ages;
    }
    ~Person(){
        cout << "destory.." << endl;
    }

};
void test1(){
    Person man = Person(100);
    Person newMan(man);
    Person newMan2 = man;//拷贝构造
//    Person newMan3;
//    newMan3 = man;


}
//值传递的方式给函数参数传值
void doWork(Person p){
    //等价于 Person p1 = p;
}
void test2(){
    Person p;
    doWork(p);
}
//以值方式返回局部变量
Person dowork2(){
    Person p = Person(20);
    cout << &p << endl;
    return p;
}

void test3(){
    Person p = dowork2();
    cout << &p << endl;
}

int main059(){
    test1();
    test2();
    test3();


    return 0;
}